home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / libg_261.zip / libg_261 / libio / libio.h < prev    next >
C/C++ Source or Header  |  1994-10-13  |  8KB  |  258 lines

  1. /* 
  2. Copyright (C) 1993 Free Software Foundation
  3.  
  4. This file is part of the GNU IO Library.  This library is free
  5. software; you can redistribute it and/or modify it under the
  6. terms of the GNU General Public License as published by the
  7. Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with GNU CC; see the file COPYING.  If not, write to
  17. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. As a special exception, if you link this library with files
  20. compiled with a GNU compiler to produce an executable, this does not cause
  21. the resulting executable to be covered by the GNU General Public License.
  22. This exception does not however invalidate any other reasons why
  23. the executable file might be covered by the GNU General Public License. */
  24.  
  25. /* This is part of the iostream library.
  26.    Copyright (C) 1991, 1992 Per Bothner. */
  27.  
  28. #ifndef _IO_STDIO_H
  29. #define _IO_STDIO_H
  30.  
  31. #if 1
  32. #include <_G_config.h>
  33. #define _IO_pos_t _G_fpos_t /* obsolete */
  34. #define _IO_fpos_t _G_fpos_t
  35. #define _IO_size_t _G_size_t
  36. #define _IO_ssize_t _G_ssize_t
  37. #define _IO_off_t _G_off_t
  38. #define _IO_pid_t _G_pid_t
  39. #define _IO_uid_t _G_uid_t
  40. #define _IO_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT
  41. #define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE
  42. #define _IO_BUFSIZ _G_BUFSIZ
  43. #define _IO_va_list _G_va_list
  44.  
  45. #ifdef _G_NEED_STDARG_H
  46. /* This define avoids name pollution if we're using GNU stdarg.h */
  47. #define __need___va_list
  48. #include <stdarg.h>
  49. #ifdef __GNUC_VA_LIST
  50. #undef _IO_va_list
  51. #define _IO_va_list __gnuc_va_list
  52. #endif /* __GNUC_VA_LIST */
  53. #endif
  54.  
  55. #else
  56. #include <_IO_config.h>
  57. typedef _IO_fpos_t _IO_pos_t;
  58. #endif
  59.  
  60. #ifndef __P
  61. #ifdef __STDC__
  62. #define __P(paramlist) paramlist
  63. #else
  64. #define __P(paramlist) ()
  65. #endif
  66. #endif /*!__P*/
  67.  
  68. /* For backward compatibility */
  69. #ifndef _PARAMS
  70. #define _PARAMS(paramlist) __P(paramlist)
  71. #endif /*!_PARAMS*/
  72.  
  73. #ifndef __STDC__
  74. #define const
  75. #endif
  76. #define _IO_USE_DTOA
  77.  
  78. #if 0
  79. #ifdef _IO_NEED_STDARG_H
  80. #include <stdarg.h>
  81. #endif
  82. #endif
  83.  
  84. #ifndef EOF
  85. #define EOF (-1)
  86. #endif
  87. #ifndef NULL
  88. #if !defined(__cplusplus) || defined(__GNUC__)
  89. #define NULL ((void*)0)
  90. #else
  91. #define NULL (0)
  92. #endif
  93. #endif
  94.  
  95. #define _IOS_INPUT    1
  96. #define _IOS_OUTPUT    2
  97. #define _IOS_ATEND    4
  98. #define _IOS_APPEND    8
  99. #define _IOS_TRUNC    16
  100. #define _IOS_NOCREATE    32
  101. #define _IOS_NOREPLACE    64
  102. #define _IOS_BIN    128
  103.  
  104. /* Magic numbers and bits for the _flags field.
  105.    The magic numbers use the high-order bits of _flags;
  106.    the remaining bits are abailable for variable flags.
  107.    Note: The magic numbers must all be negative if stdio
  108.    emulation is desired. */
  109.  
  110. #define _IO_MAGIC 0xFBAD0000 /* Magic number */
  111. #define _OLD_STDIO_MAGIC 0xFABC0000 /* Emulate old stdio. */
  112. #define _IO_MAGIC_MASK 0xFFFF0000
  113. #define _IO_USER_BUF 1 /* User owns buffer; don't delete it on close. */
  114. #define _IO_UNBUFFERED 2
  115. #define _IO_NO_READS 4 /* Reading not allowed */
  116. #define _IO_NO_WRITES 8 /* Writing not allowd */
  117. #define _IO_EOF_SEEN 0x10
  118. #define _IO_ERR_SEEN 0x20
  119. #define _IO_DELETE_DONT_CLOSE 0x40
  120. #define _IO_LINKED 0x80 /* Set if linked (using _chain) to streambuf::_list_all.*/
  121. #define _IO_IN_BACKUP 0x100
  122. #define _IO_LINE_BUF 0x200
  123. #define _IO_TIED_PUT_GET 0x400 /* Set if put and get pointer logicly tied. */
  124. #define _IO_CURRENTLY_PUTTING 0x800
  125. #define _IO_IS_APPENDING 0x1000
  126. #define _IO_IS_FILEBUF 0x2000
  127.  
  128. /* These are "formatting flags" matching the iostream fmtflags enum values. */
  129. #define _IO_SKIPWS 01
  130. #define _IO_LEFT 02
  131. #define _IO_RIGHT 04
  132. #define _IO_INTERNAL 010
  133. #define _IO_DEC 020
  134. #define _IO_OCT 040
  135. #define _IO_HEX 0100
  136. #define _IO_SHOWBASE 0200
  137. #define _IO_SHOWPOINT 0400
  138. #define _IO_UPPERCASE 01000
  139. #define _IO_SHOWPOS 02000
  140. #define _IO_SCIENTIFIC 04000
  141. #define _IO_FIXED 010000
  142. #define _IO_UNITBUF 020000
  143. #define _IO_STDIO 040000
  144. #define _IO_DONT_CLOSE 0100000
  145.  
  146. /* A streammarker remembers a position in a buffer. */
  147.  
  148. struct _IO_jump_t;  struct _IO_FILE;
  149.  
  150. struct _IO_marker {
  151.   struct _IO_marker *_next;
  152.   struct _IO_FILE *_sbuf;
  153.   /* If _pos >= 0
  154.  it points to _buf->Gbase()+_pos. FIXME comment */
  155.   /* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */
  156.   int _pos;
  157. #if 0
  158.     void set_streampos(streampos sp) { _spos = sp; }
  159.     void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); }
  160.   public:
  161.     streammarker(streambuf *sb);
  162.     ~streammarker();
  163.     int saving() { return  _spos == -2; }
  164.     int delta(streammarker&);
  165.     int delta();
  166. #endif
  167. };
  168.  
  169. struct _IO_FILE {
  170.   int _flags;        /* High-order word is _IO_MAGIC; rest is flags. */
  171. #define _IO_file_flags _flags
  172.  
  173.   /* The following pointers correspond to the C++ streambuf protocol. */
  174.   char* _IO_read_ptr;    /* Current read pointer */
  175.   char* _IO_read_end;    /* End of get area. */
  176.   char* _IO_read_base;    /* Start of putback+get area. */
  177.   char* _IO_write_base;    /* Start of put area. */
  178.   char* _IO_write_ptr;    /* Current put pointer. */
  179.   char* _IO_write_end;    /* End of put area. */
  180.   char* _IO_buf_base;    /* Start of reserve area. */
  181.   char* _IO_buf_end;    /* End of reserve area. */
  182.   /* The following fields are used to support backing up and undo. */
  183.   char *_IO_save_base; /* Pointer to start of non-current get area. */
  184.   char *_IO_backup_base;  /* Pointer to first valid character of backup area */
  185.   char *_IO_save_end; /* Pointer to end of non-current get area. */
  186.  
  187.   struct _IO_marker *_markers;
  188.   
  189.   struct _IO_FILE *_chain;
  190.   
  191.   struct _IO_jump_t *_jumps; /* Jump table */
  192.   
  193.   int _fileno;
  194.   int _blksize;
  195.   _IO_off_t _offset;
  196.   
  197. #define __HAVE_COLUMN /* temporary */
  198.   /* 1+column number of pbase(); 0 is unknown. */
  199.   unsigned short _cur_column;
  200.   char _unused;
  201.   char _shortbuf[1];
  202.   
  203.   /*  char* _save_gptr;  char* _save_egptr; */
  204. };
  205.  
  206. #ifndef __cplusplus
  207. typedef struct _IO_FILE _IO_FILE;
  208. #endif
  209.  
  210. struct _IO_FILE_plus;
  211. extern struct _IO_FILE_plus _IO_stdin_, _IO_stdout_, _IO_stderr_;
  212. #define _IO_stdin ((_IO_FILE*)(&_IO_stdin_))
  213. #define _IO_stdout ((_IO_FILE*)(&_IO_stdout_))
  214. #define _IO_stderr ((_IO_FILE*)(&_IO_stderr_))
  215.  
  216. #ifdef __cplusplus
  217. extern "C" {
  218. #endif
  219.  
  220. extern int __underflow __P((_IO_FILE*));
  221. extern int __uflow __P((_IO_FILE*));
  222. extern int __overflow __P((_IO_FILE*, int));
  223.  
  224. extern unsigned __adjust_column __P((unsigned start, const char *line, int count));
  225.  
  226. #define _IO_getc(_fp) \
  227.        ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end ? __uflow(_fp) \
  228.     : *(unsigned char*)(_fp)->_IO_read_ptr++)
  229. #define _IO_peekc(_fp) \
  230.        ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end \
  231.       && __underflow(_fp) == EOF ? EOF \
  232.     : *(unsigned char*)(_fp)->_IO_read_ptr)
  233.  
  234. #define _IO_putc(_ch, _fp) \
  235.    (((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \
  236.     ? __overflow(_fp, (unsigned char)(_ch)) \
  237.     : (unsigned char)(*(_fp)->_IO_write_ptr++ = (_ch)))
  238.  
  239. #define _IO_feof(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)
  240. #define _IO_ferror(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)
  241.  
  242. /* This one is for Emacs. */
  243. #define _IO_PENDING_OUTPUT_COUNT(_fp)    \
  244.     ((_fp)->_IO_write_ptr - (_fp)->_IO_write_base)
  245.  
  246. extern int _IO_vfscanf __P((_IO_FILE*, const char*, _IO_va_list, int*));
  247. extern int _IO_vfprintf __P((_IO_FILE*, const char*, _IO_va_list));
  248. extern _IO_ssize_t _IO_padn __P((_IO_FILE *, int, _IO_ssize_t));
  249. extern _IO_size_t _IO_sgetn __P((_IO_FILE *, void*, _IO_size_t));
  250.  
  251. extern void _IO_free_backup_area __P((_IO_FILE*));
  252.  
  253. #ifdef __cplusplus
  254. }
  255. #endif
  256.  
  257. #endif /* _IO_STDIO_H */
  258.